﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace Lf_VoteSys.Models.Database
{
    public partial class Lf_VoteSysContext : DbContext
    {
        public Lf_VoteSysContext()
        {
        }

        public Lf_VoteSysContext(DbContextOptions<Lf_VoteSysContext> options)
            : base(options)
        {
        }

        public virtual DbSet<FenlBiao> FenlBiaos { get; set; }
        public virtual DbSet<Topiao> Topiaos { get; set; }
        public virtual DbSet<UserBiao> UserBiaos { get; set; }
        public virtual DbSet<ZiliaoBiao> ZiliaoBiaos { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=DANCON\\MSSQLSERVER2018;Initial Catalog=Lf_VoteSys;Integrated Security=SSPI");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<FenlBiao>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("FenlBiao");

                entity.Property(e => e.FenName)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("fenName");

                entity.Property(e => e.Fenld).HasColumnName("fenld");
            });

            modelBuilder.Entity<Topiao>(entity =>
            {
                entity.HasKey(e => new { e.UserId, e.ZiliaoId });

                entity.ToTable("Topiao");

                entity.Property(e => e.ZiliaoId).HasColumnName("ziliaoId");

                entity.Property(e => e.Piaosshu).HasColumnName("piaosshu");
            });

            modelBuilder.Entity<UserBiao>(entity =>
            {
                entity.HasKey(e => e.UserId);

                entity.ToTable("UserBiao");

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.Salt)
                    .HasMaxLength(4)
                    .IsUnicode(false)
                    .IsFixedLength(true);

                entity.Property(e => e.UserEmail)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.UserName).HasMaxLength(100);

                entity.Property(e => e.UserPwd)
                    .IsRequired()
                    .HasMaxLength(50);
            });

            modelBuilder.Entity<ZiliaoBiao>(entity =>
            {
                entity.HasKey(e => e.ZiliaoId);

                entity.ToTable("ZiliaoBiao");

                entity.Property(e => e.ZiliaoId).HasColumnName("ziliaoId");

                entity.Property(e => e.Logo)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.ZiliaoJj)
                    .IsRequired()
                    .HasMaxLength(255)
                    .HasColumnName("ziliaoJj");

                entity.Property(e => e.ZiliaoName)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("ziliaoName");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
